package com.mmy.service.impl.restaurant;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.restaurant.TRestaurantPlanRepository;
import com.mmy.dao.restaurant.VRestaurantBaseRepository;
import com.mmy.dao.restaurant.VRestaurantPlanRepository;
import com.mmy.domain.restaurant.VRestaurantBase;
import com.mmy.domain.restaurant.VRestaurantPlan;
import com.mmy.service.restaurant.RestaurantPlanService;

@Service
public class RestaurantPlanServiceImpl implements RestaurantPlanService {
	@Autowired
	VRestaurantBaseRepository vRestaurantBaseRepository;
	@Autowired
	VRestaurantPlanRepository vRestaurantPlanRepository;
	@Autowired
	TRestaurantPlanRepository tRestaurantPlanRepository;

	/**
	 * 通过计划单ID查询
	 *
	 * @author 创建人 hanxl 整理
	 * @date 创建日期 2020.10.29
	 */
	public VRestaurantPlan findByPlanID(int iPlanID) {
		// TODO Auto-generated method stub
		return vRestaurantPlanRepository.findByPlanID(iPlanID);
	}

	/**
	 * 前台景区菜单首页显示查询计划日期大于当前日期的景区ID
	 * 
	 * @author 创建人 hanxl
	 * @date 创建日期 2021.01.13
	 */
	public List<Integer> getRestID(String strRestPrice1, String strRestPrice2) {
		if (strRestPrice1 == null) {
			strRestPrice1 = "";
		}
		if (strRestPrice2 == null) {
			strRestPrice2 = "";
		}
		List<Integer> lstRestID = tRestaurantPlanRepository.getRestID(strRestPrice1, strRestPrice2);
		return lstRestID;
	}

	/**
	 * 函数功能说明：前台景点菜单显示信息
	 *
	 * @param 参数说明
	 * @return 返回值说明 jsp页面
	 * @throws 异常处理说明
	 * @author 创建人hanxl
	 * @param pageSize
	 * @param pageNumber
	 * @param iZoneID
	 * @param strScenicName
	 * @date 创建日期2020.12.25
	 */
	public List<VRestaurantBase> findBySearch(String pageNumber, String pageSize, List<Integer> lstRestID, int iZoneID,
			String strRestName) {
		int iPageSize = 0;
		int iTempPageNo = 0;
		if (strRestName == null) {
			strRestName = "";
		}
		if (pageNumber == null) {
			pageNumber = "1";
		}
		if (pageSize == null) {
			iPageSize = 20;
		} else {
			iPageSize = Integer.valueOf(pageSize);
			iTempPageNo = (Integer.valueOf(pageNumber) - 1) * iPageSize;
		}
		List<VRestaurantBase> lstRestBase = vRestaurantBaseRepository.findBySearch(lstRestID, iZoneID, strRestName,
				iTempPageNo, iPageSize);
		return lstRestBase;
	}

	/**
	 * 前台景区菜单首页显示查询这些景区ID的计划日期大于当前日期的计划最小价格
	 * 
	 * @author 创建人 hanxl
	 * @date 创建日期 2021.01.13
	 */

	public List<VRestaurantPlan> getMinPrice() {
		List<VRestaurantPlan> lstRestPlan = vRestaurantPlanRepository.getMinPrice();
		return lstRestPlan;
	}

	/**
	 * 通过景区ID查询
	 *
	 * 后台查询该景区详细信息时用到 以开始时间倒序
	 * 
	 * @author 修改人 hanxl
	 * @date 创建日期2021.01.14
	 */
	public List<VRestaurantPlan> getByRestaurantID(String strRestaurantID) {
		int iRestaurantID = Integer.valueOf(strRestaurantID);
		List<VRestaurantPlan> lstRestaurantPlan = vRestaurantPlanRepository.getByRestaurant(iRestaurantID);
		return lstRestaurantPlan;
	}

}
